package com.hospital.hospitaldrugservice.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hospital.common.dto.DrugDto;
import com.hospital.hospitaldrugservice.entity.Drug;
import com.hospital.hospitaldrugservice.mapper.DrugMapper;
import com.hospital.hospitaldrugservice.service.IDrugService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 药品表 服务实现类
 * </p>
 *
 * @author 王晓康
 * @since 2020-10-20
 */
@Service
public class DrugServiceImpl extends ServiceImpl<DrugMapper, Drug> implements IDrugService {

    @Override
    public IPage<Drug> selectPageDto(Page page, DrugDto dto) {
        IPage<Drug> drugIPage = this.baseMapper.selectPageDto(page, dto);
        return drugIPage;
    }

    @Override
    public void updDrug(DrugDto dto) {
        this.baseMapper.updDrug(dto);
    }

    @Override
    public Integer getLastDrugnumber() {
        Drug lastDrugnumber = this.baseMapper.getLastDrugnumber();
        Integer drugnumber = new Integer(lastDrugnumber.getDrugnumber());
        return drugnumber+1;
    }

    @Override
    public void addDrug(DrugDto dto) {
        this.baseMapper.addDrug(dto);
    }
}
